import com.sun.corba.se.impl.presentation.rmi.StubConnectImpl;

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;

class Student implements Comparable<Student> {
    int id;

    @Override
    public int compareTo(Student o) {
        return -(this.id - o.id);
    }

    public Student(int id) {
        this.id = id;
    }
}

public class Test {
    public static void main(String[] args) {
        TestHeap testHeap = new TestHeap();
        int[] array = {27,15,19,18,28,34,65,49,25,37};
        testHeap.initHeap(array);
        testHeap.createHeap();
        testHeap.heapSort();
        System.out.println("-=");
    }
    public static void main2(String[] args) {
//        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
//        priorityQueue.offer(1);
//        priorityQueue.offer(5);
//        priorityQueue.offer(2);
//        priorityQueue.offer(7);
//        priorityQueue.offer(3);
//        priorityQueue.offer(23);
//        priorityQueue.offer(31);
//
//        System.out.println(priorityQueue.poll());
//        System.out.println(priorityQueue.poll());
//        System.out.println(priorityQueue.poll());
//        System.out.println(priorityQueue.poll());
//        System.out.println(priorityQueue.poll());
//        System.out.println(priorityQueue.poll());

//        PriorityQueue<Student> priorityQueue1 = new PriorityQueue<>();
//        priorityQueue1.offer(new Student(3));
//        priorityQueue1.offer(new Student(7));
//        priorityQueue1.offer(new Student(4));
//        priorityQueue1.offer(new Student(5));
//        System.out.println(priorityQueue1.poll().id);
//        System.out.println(priorityQueue1.poll().id);
//        System.out.println(priorityQueue1.poll().id);
//        System.out.println(priorityQueue1.poll().id);

        PriorityQueue<Student> priorityQueue1 = new PriorityQueue<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.id-o2.id;
            }
        });
        priorityQueue1.offer(new Student(3));
        priorityQueue1.offer(new Student(7));
        priorityQueue1.offer(new Student(4));
        priorityQueue1.offer(new Student(5));
        System.out.println(priorityQueue1.poll().id);
        System.out.println(priorityQueue1.poll().id);
        System.out.println(priorityQueue1.poll().id);
        System.out.println(priorityQueue1.poll().id);
    }
    public static void main1(String[] args) {
        TestHeap testHeap = new TestHeap();
        int[] array = {27,15,19,18,28,34,65,49,25,37};
        testHeap.initHeap(array);
        testHeap.createHeap();
        System.out.println("==插入元素==");

        testHeap.offer(80);
        System.out.println("===删除===");
        System.out.println(Arrays.toString(testHeap.elem));
        System.out.println(testHeap.poll());
        System.out.println(Arrays.toString(testHeap.elem));
        System.out.println(testHeap.poll());
    }
}
